	

    <section>
			<ul class="breadcrumb">
			  <li><a href="<?php echo base_url('index.php/mainController/'); ?>">Home</a> <span class="divider">/</span></li>
			  <li class="active">จัดการแฟ้มสำนวนคดี</li>
			</ul>

      <div class="page-header">
      	
        <h1>จัดการแฟ้มสำนวนคดี</h1>
     	</div>


      <a class="btn btn-primary pull-right toggle-all" href="<?php echo base_url('index.php/borrowingSystemController/create_casefile'); ?>">เพิ่มแฟ้มสำนวนคดี</a>
      <form class="form-horizontal">
        <div class="control-group">
          <label class="control-label" for="ืnamecase"></label>
          <div class="controls form-inline">
            <input type="text" id="ืnamecase" placeholder="คำค้น">
            <button type="button" id="btnFind" name="btnFind" class="btn btn-primary"><i class="icon-search icon-white"></i> ค้นหา</button>
          </div>
        </div>
      </form>

      <div id="test"></div>

     	<div>
     		<table id="tbCaseFile" class="table table-striped table-condensed">
     			<thead>
     				<th>รหัสคดี</th>
     				<th>รายคดี/ชื่อคดี</th>
     				<th>จำนวนแฟ้มสำนวนคดีทั้งหมด</th>
     				<th>รายละเอียด</th>
            <th colspan="3" style="text-align:center;">ปรับแต่ง</th>
     			</thead>
     			<tbody>

     			</tbody>
     		</table>
     	</div>

    </section>

    <script>
    var caseFile = <?php echo $jsonCaseFile ?>;
    var htmlListFile = '';
    $.each( caseFile, function( key, value ) {
      htmlListFile += "<tr>";
      htmlListFile += "<td>"+caseFile[key].file_caseid+"</td>";
      htmlListFile += "<td>"+caseFile[key].file_casename+"</td>";
      htmlListFile += "<td>"+caseFile[key].doc_amt+"</td>";
      htmlListFile += "<td>"+caseFile[key].file_casedetail+"</td>";
      htmlListFile += "<td><a href='#show_allfile' data-toggle='modal' data-id='"+caseFile[key].file_id+"' class='open_allfile' >ดูแฟ้มทั้งหมด</a></td>";
      htmlListFile += "<td><a href='<?php echo base_url(); ?>index.php/borrowingSystemController/edit_casefile/"+caseFile[key].file_id+"' >แก้ไข</a></td>";
      if (caseFile[key].file_status == 'Y') {
        htmlListFile += "<td><a id='"+caseFile[key].file_id+"' class='changeStatus' data-status='"+caseFile[key].file_status+"'>ใช้งาน</a></td>";
      }else{
        htmlListFile += "<td><a id='"+caseFile[key].file_id+"' class='changeStatus'  data-status='"+caseFile[key].file_status+"'>ไม่ใช้งาน</a></td>";
      }
      
      
      htmlListFile += "</tr>";
    });

    $('#tbCaseFile tbody').html(htmlListFile);
    </script>


    <!-- Script Modal -->
    <script type="text/javascript">

      $(function(){
        $('.changeStatus').on('click',function(){
          var item_id = $(this).attr('id');
          var item_status = $(this).data('status');
          //alert(item_status);
          
          $.ajax({
            type: "POST",
            url: '<?php echo base_url(); ?>index.php/borrowingSystemController/change_status',
            data: { id :item_id , status : item_status },
            success: function(data){
              if(data == "1"){
                
              }else{
                alert("พบข้อผิดพลาด");
                return;
              }
            },
            error : function(error){
              var err = '';
              for(er in error){
                err += er;
              }
              alert(err);
            }
          });

          if (item_status == 'Y') {
            $(this).data('status','N');
            $(this).html('ไม่ใช้งาน');
            //alert($(this).data('status'));
          }else{
            $(this).data('status','Y');
            $(this).html('ใช้งาน');
            //alert($(this).data('status'));
          }

        });

        $('.open_allfile').on('click',function(){
          var filecase = $(this).data('id');
          alert(filecase);
          $("#caseid").html(filecase);
        });

      });

    </script>

    <!-- Modal -->
    <div id="show_allfile" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
        <h3 id="myModalLabel">รายการแฟ้มสำนวนคดี - <span id="caseid"></span></h3>
      </div>
      <div class="modal-body">
        <form class="form-horizontal">

          <div class="control-group">
            <label class="control-label" for="own">รหัสคดี</label>
            <div class="controls">
              <input type="text" id="own" placeholder="รหัสคดี">
            </div>
          </div>

          <div class="control-group">
            <label class="control-label" for="ืnamecase">รายคดี/ชื่อคดี</label>
            <div class="controls">
              <input type="text" id="ืnamecase" placeholder="รายคดี/ชื่อคดี">
            </div>
          </div>

          <div style="overflow: auto;">
            <table class="table table-striped table-condensed" >
              <thead>
                <th>ลำดับที่</th>
                <th>แฟ้มสำนวนคดี</th>
                <th>ชื่อแฟ้ม</th>
                <th></th>
              </thead>
              <tbody>
                <tr >
                  <td>1</td>
                  <td>2/1</td>
                  <td>นายกอ</td>
                  <td><input type="checkbox"></td>
                </tr>
                <tr >
                  <td>2</td>
                  <td>2/1</td>
                  <td>นายขอ</td>
                  <td><input type="checkbox"></td>
                </tr>
              </tbody>
            </table>
          </div>

        </form>

      </div>
      <div class="modal-footer">
        <button class="btn" data-dismiss="modal" aria-hidden="true">ย้อนกลับ</button>
        <button class="btn btn-primary">ตกลง</button>
      </div>
    </div>